<?php

class PdoSexe extends PdoConnect {



    public function readAll() {
        try {
            $this->open();
            $sql = "SELECT * FROM `sexe` ORDER BY INTITULESEXE";
            $prep = $this->pdo->prepare($sql);

            $prep->execute();
            $prep->setFetchMode(PDO::FETCH_ASSOC);


            return $prep;
        } catch (PDOException $e) {
            $msg = 'ERREUR PDO dans ' . $e->getFile() . ' L.' . $e->getLine() . ' : ' . $e->getMessage();
            die($msg);
        }
    }
    
     public function update(sexe $sexe) {
        try {
            $this->open();
            $sql = "UPDATE `sexe` SET INTITULESEXE= ? WHERE IDSEXE=?";

            $prep = $this->pdo->prepare($sql);

            $prep->bindValue(1, $pays->get(), PDO::PARAM_STR);
            $prep->bindValue(2, $pays->getIdSexe(), PDO::PARAM_INT);

            $prep->execute();
        } catch (PDOException $e) {
            $msg = 'ERREUR PDO dans ' . $e->getFile() . ' L.' . $e->getLine() . ' : ' . $e->getMessage();
            die($msg);
        }
    }

    public function readOne($IdSexe) {
        try {
            $this->open();
            $sql = "SELECT * FROM `Sexe` WHERE IDSEXE=$IdSexe";
            $prep = $this->pdo->prepare($sql);

            $prep->execute();

            $sexe = new Sexe();
            $ligne = $prep->fetch(PDO::FETCH_OBJ);
            $sexe->setIdSexe($ligne->IDSSEXE);
            $sexe->setIntituleSexe($ligne->INTITULESEXE);
            

            return $sexe;
        } catch (PDOException $e) {
            $msg = 'ERREUR PDO dans ' . $e->getFile() . ' L.' . $e->getLine() . ' : ' . $e->getMessage();
            die($msg);
        }
    }



}
